package com.xsd.principle.singleresponsibility;

/**
 * @Description: 单一职责原则
 * @Author: zhoufuzong
 * @Created: 2021-01-16 17:12:09
 * @Version: 1.1.0
 */

public class SingleRsponsibility2 {

    public static void main(String[] args) {
        RoadVehicle vehicle = new RoadVehicle();
        vehicle.run("摩托车");
        vehicle.run("汽车");


        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");


    }


}
/*
    方案2的分析
    1. 遵守了的单一职责原则
    2. 但是这样做的改动很大，即将类分解，同时修改客户端
    3. 改进：直接修改Vehicle 类，改动的代码会比较少
 */

class RoadVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "公路运行");

    }

}
class AirVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "天空运行");
    }

}

class WaterVehicle{
    public void run(String vehicle){
        System.out.println(vehicle + "水中运行");

    }

}


